﻿using StackExchange.Redis;
using System;
using System.Collections.Generic;
using System.Text;

namespace Drive.LiveExcelHost
{
    class RedisWebSocketSession
    {
        private static ConnectionMultiplexer redis = ConnectionMultiplexer.Connect(RedisConf.connectionString);
        public static long Increase(string uid)
        {
            return redis.GetDatabase(2).HashIncrement("ws_session_count", uid, 1);
        }

        public static long Decrease(string uid)
        {
            return redis.GetDatabase(2).HashDecrement("ws_session_count", uid, 1);
        }

        public static void Reset()
        {
            redis.GetDatabase(2).KeyDelete("ws_session_count");

        }

        public static long GetUserCount()
        {
            return redis.GetDatabase(2).HashLength("ws_session_count");
        }
    }
}
